#include <iostream>
#include <unordered_map>

using namespace std;

int y, m, d;
int dom[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
unordered_map<int,int> c;

int sum(int num)
{
    int result = 0;
    while(num)
    {
        result += num%10;
        num /= 10;
    }
    return result;
}

int main()
{
    for(int i=0;i<10;i++){c[i*i]=1;}

    int result = 0;
    y=2001;m=1;d=1;

    while(true)
    {
        if(c[ sum(y)+sum(m)+sum(d) ]==1){result++;}

        if(y==2021 && m==12 && d==31){break;}

        if(++d>dom[m])
        {
            d=1;
            if(++m>12)
            {
                m = 1;
                y++;
                if((y%4==0 && y%100!=0)||y%400==0)
                    {dom[2]=29;}
                else
                    {dom[2]=28;}
            }
        }
    }

    cout<<result;
    return 0;
}
